function add0(m) {
  return m < 10 ? '0' + m : m
}

function formatTime(Time) {
  //shijianchuo是整数，否则要parseInt转换
  var time = new Date(Time);
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var h = time.getHours();
  var mm = time.getMinutes();
  var s = time.getSeconds();
  return y + '-' + add0(m) + '-' + add0(d)+ '  ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
}

function getOffsetTopToBody(dom) {
  let bodyDom = dom;
  let localTop = dom.offsetTop;
  if (bodyDom.offsetTop === 50) {
    localTop = dom.offsetTop
  } else {
    while (bodyDom.offsetTop !== 50) {
      bodyDom = bodyDom.parentElement;
      localTop += bodyDom.offsetTop
    }
  }
  return {
    bodyDom,
    localTop
  }
}

function bounded(fn, time) {
  let again = true
  return function() {
    console.log(again)
    if (again) {
      again = false
      setTimeout(() => {
        again = true
      }, time)
      return fn
    }
  }
}
module.exports = {
  formatTime,
  getOffsetTopToBody,
  bounded
}